const defaultList = {
  list: [{ list: "123", id: "123137987" }],
  listed: [],
};

export const reducer = (state = defaultList, action) => {
  switch (action.type) {
    case "addList":
      return { ...state, list: [action.data, ...state.list] };
    case "addListed":
      console.log(action.data);
      return {
        list: state.list.filter((value) => value.id !== action.data),
        listed: [
          ...state.listed,
          ...state.list.filter((value) => value.id === action.data),
        ],
      };
    case "addListedtoList":
      return {
        listed: state.listed.filter((value) => value.id !== action.data),
        list: [
          ...state.list,
          ...state.listed.filter((value) => value.id === action.data),
        ],
      };
    default:
      return state;
  }
};
